package org.cfg;

import com.sojoys.artifact.build.data.base.BaseCfg;
import java.util.List;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.tools.ToolCopy;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.ArrayUtils;
import com.sojoys.artifact.tools.SK_String;
import com.xiaoleilu.hutool.util.StrUtil;
import com.sojoys.artifact.constant.DataModelKeyEnum;
/**
 * 召唤
 */
public class SummonCfg extends BaseCfg<SummonCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "summon";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.SummonCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 9;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","召唤类型","抽卡次数","消耗","获得道具","池类型","高级道具数量","高级物品品质范围","道具类型数量限制",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","summonType","cardCount","cost","goods","poolType","rareItemNum","minQuality","itemTypeNum",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","summonType","cardCount","cost","goods","poolType","rareItemNum","minQuality","itemTypeNum",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,80473019,-271036449,3059661,98539350,635121014,-1051284367,2183757,-1387023527,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","int","int","List","Map","int","Map","int[]","Map",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Integer.class,Integer.class,List.class,Map.class,Integer.class,Map.class,int[].class,Map.class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 召唤类型
	 */
	private int summonType;
	
	/**
	 * 抽卡次数
	 */
	private int cardCount;
	
	/**
	 * 消耗
	 */
	private List cost;
	
	/**
	 * 获得道具
	 */
	private Map goods;
	
	/**
	 * 池类型
	 */
	private int poolType;
	
	/**
	 * 高级道具数量
	 */
	private Map rareItemNum;
	
	/**
	 * 高级物品品质范围
	 */
	private int[] minQuality;
	
	/**
	 * 道具类型数量限制
	 */
	private Map itemTypeNum;
	
	
	
	public static SummonCfg builder() {
		SummonCfg summonCfg = new SummonCfg();
		return summonCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 召唤类型
	 */
	public int getSummonType() {
		return summonType;
	}
	
	/**
	 * 抽卡次数
	 */
	public int getCardCount() {
		return cardCount;
	}
	
	/**
	 * 消耗
	 */
	public List getCost() {
		return cost;
	}
	
	/**
	 * 获得道具
	 */
	public Map getGoods() {
		return goods;
	}
	
	/**
	 * 池类型
	 */
	public int getPoolType() {
		return poolType;
	}
	
	/**
	 * 高级道具数量
	 */
	public Map getRareItemNum() {
		return rareItemNum;
	}
	
	/**
	 * 高级物品品质范围
	 */
	public int[] getMinQuality() {
		return minQuality;
	}
	
	/**
	 * 道具类型数量限制
	 */
	public Map getItemTypeNum() {
		return itemTypeNum;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.summonType;
        values[2] = this.cardCount;
        values[3] = this.cost;
        values[4] = this.goods;
        values[5] = this.poolType;
        values[6] = this.rareItemNum;
        values[7] = this.minQuality;
        values[8] = this.itemTypeNum;
        return values;
	}
	
	protected SummonCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.summonType = (int)vals[1];
		this.cardCount = (int)vals[2];
		this.cost = (List)vals[3];
		this.goods = (Map)vals[4];
		this.poolType = (int)vals[5];
		this.rareItemNum = (Map)vals[6];
		this.minQuality = (int[])vals[7];
		this.itemTypeNum = (Map)vals[8];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.summonType);
        map.put(keys[2], this.cardCount);
        map.put(keys[3], this.cost);
        map.put(keys[4], this.goods);
        map.put(keys[5], this.poolType);
        map.put(keys[6], this.rareItemNum);
        map.put(keys[7], this.minQuality);
        map.put(keys[8], this.itemTypeNum);
        return map;
    }
    
    protected SummonCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.summonType = (int)map.get(keys[1]);
   		this.cardCount = (int)map.get(keys[2]);
   		this.cost = (List)map.get(keys[3]);
   		this.goods = (Map)map.get(keys[4]);
   		this.poolType = (int)map.get(keys[5]);
   		this.rareItemNum = (Map)map.get(keys[6]);
   		this.minQuality = (int[])map.get(keys[7]);
   		this.itemTypeNum = (Map)map.get(keys[8]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.summonType);
        obj.put(keys[2], this.cardCount);
        obj.put(keys[3], this.cost);
        obj.put(keys[4], this.goods);
        obj.put(keys[5], this.poolType);
        obj.put(keys[6], this.rareItemNum);
        obj.put(keys[7], this.minQuality);
        obj.put(keys[8], this.itemTypeNum);
        return obj;
    }
    
    protected SummonCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.summonType = obj.getIntValue(keys[1]);
	    this.cardCount = obj.getIntValue(keys[2]);
		this.cost = obj.getObject(keys[3],List.class);
		this.goods = obj.getObject(keys[4],Map.class);
	    this.poolType = obj.getIntValue(keys[5]);
		this.rareItemNum = obj.getObject(keys[6],Map.class);
		this.minQuality = obj.getObject(keys[7],int[].class);
		this.itemTypeNum = obj.getObject(keys[8],Map.class);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeInt(this.summonType);
	    byteBuf.writeInt(this.cardCount);
	    byteBuf.writeObject(this.cost);
	    byteBuf.writeObject(this.goods);
	    byteBuf.writeInt(this.poolType);
	    byteBuf.writeObject(this.rareItemNum);
	    byteBuf.writeObject(this.minQuality);
	    byteBuf.writeObject(this.itemTypeNum);
    }
	
	protected SummonCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.summonType = byteBuf.readInt(null);
	    this.cardCount = byteBuf.readInt(null);
	    this.cost = (List)byteBuf.readObject();
	    this.goods = (Map)byteBuf.readObject();
	    this.poolType = byteBuf.readInt(null);
	    this.rareItemNum = (Map)byteBuf.readObject();
	    this.minQuality = byteBuf.readIntArray(null);
	    this.itemTypeNum = (Map)byteBuf.readObject();
	    return this;
	}
	
	public SummonCfg deepCopy(){
		SummonCfg summonCfg = null;
		try {
			summonCfg = (SummonCfg) super.clone();
		    summonCfg.cost = ToolCopy.copyObject(this.cost);
		    summonCfg.goods = ToolCopy.copyObject(this.goods);
		    summonCfg.rareItemNum = ToolCopy.copyObject(this.rareItemNum);
		    summonCfg.minQuality = ToolCopy.copyObject(this.minQuality);
		    summonCfg.itemTypeNum = ToolCopy.copyObject(this.itemTypeNum);
			return summonCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return summonCfg;
	}
//自定义内容起始位置
//自定义内容结束位置
}
